<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">
		var str = "saasdfaaaaaa";
		var json = {};
		for (var i = 0;i<str.length;i++) {
			console.log(str.charAt(i))
//			console.log(json[str.charAt(i)])//undefined
			if (!json[str.charAt(i)]) {  
				  //ruguo meiyou 
				  json[str.charAt(i)] = 1
			} else{
				json[str.charAt(i)]++
			}
		};
		console.log(JSON.stringify(json))
		
		var iMax = 0;
		var iIndex = "";
		for (var i in json) {
			if(json[i] > iMax){
				iMax = json[i];
				iIndex = i;
			}
			
		}
		
		console.log(iIndex + "出现了" + iMax + "次")
		
	</script>
</html>
